//
//  MovieTableViewCell.m
//  豆瓣终极版
//
//  Created by dllo on 15/12/18.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "MovieTableViewCell.h"
#import "UIImageView+WebCache.h"
@interface MovieTableViewCell ()

@property (nonatomic, retain) UIImageView *backGroundImageView;
@property (nonatomic, retain) UIImageView *moviePicView;
@property (nonatomic, retain) UILabel *movieNameLabel;

@end
@implementation MovieTableViewCell

- (void)dealloc{
    [_backGroundImageView release];
    [_moviePicView release];
    [_movieNameLabel release];
    [super dealloc];
}
// 重写cell的初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

- (void)createSubView{
    self.backGroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 350, 200)];
    self.backGroundImageView.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    [self.contentView addSubview:self.backGroundImageView];
    [_backGroundImageView release];
    
    self.moviePicView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 130, 185)];
    self.moviePicView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.moviePicView];
    [_moviePicView release];
    
    self.movieNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(155, 80, 200, 40)];
    self.movieNameLabel.text = @"龟兔赛跑";
    [self.contentView addSubview:self.movieNameLabel];
    [_movieNameLabel release];
    
}

- (void)setMovie:(Movie *)movie{
    if (_movie != movie) {
        [_movie release];
        _movie = [movie retain];
    }
    NSURL *url = [NSURL URLWithString:_movie.pic_url];
    [self.moviePicView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"picholder.png"]];
    self.movieNameLabel.text = _movie.movieName;
    
}
@end
